// pages/editor/editor.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    endDate:'',
    TicketCode:'',
    TicketNub:'',
    Price:'',
    Date:'',
    CheckCode:''
   
  },
 
  TicketCodeEditor: function (e) {
    var that = this
    console.log('---------', e.detail.value)
    that.setData({
      TicketCode: e.detail.value
    })

  },

  TicketNubEditor:function(e){
    var that = this

    console.log('---------',e.detail.value)
    that.setData({
      TicketNub: e.detail.value
    })

  },

  PriceEditor: function (e) {
    var that = this

    console.log('---------', e.detail.value)
    that.setData({
      Price: e.detail.value
    })

  },
  CheckCodeEditor: function (e) {
    var that = this

    console.log('---------', e.detail.value)
    that.setData({
      CheckCode: e.detail.value
    })

  },

  
 /**
  * 跳转创建二维码
  */
  CreatQrcode:function(){
    var that = this
    var url = '01,10,' + that.data.TicketCode + ',' + that.data.TicketNub + ',' + that.data.Price + ',' + that.data.Date + ',' + that.data.CheckCode + ','+'291A' 

    wx.navigateTo({
      url: '../creatqrcode/creatqrcode?qrurl='+url,
    })

  },

  dateChange:function(e){
    var that = this

    console.log('-------日期：',e)
    that.setData({
      Date: e.detail.value.replace(/-/g, '')
    })

  },
  GetEndDate: function (date) {
    var year = date.getFullYear()
    var month = date.getMonth() + 1
    var day = date.getDate()
    return year+'-'+ month+'-'+ day
  },



  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    var end = that.GetEndDate(new Date())
    console.log('日期', end)
    that.setData({
      endDate:end
    })

    console.log('接收信息', options.info)
    if (options.info){
      var resultArr = options.info.split(",")
      var ticketCode = resultArr[2]
      var ticketNub = resultArr[3]
      var price = resultArr[4]
      var date = resultArr[5]
      var checkCode = resultArr[6]

      console.log('--------发票代码:', ticketCode)
      console.log('--------发票号码:', ticketNub)
      console.log('--------合计金额:', price)
      console.log('--------开票日期:', date)
      console.log('--------发票校验码:', checkCode)
      that.setData({
        TicketCode: ticketCode,
        TicketNub: ticketNub,
        Price: price,
        Date: date,
        CheckCode: checkCode
      })
    }else{

    }

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})